import time

import smbus

iic = smbus.SMBus(1)
wbuf = [1, 2, 3, 4, 5, 6, 7, 8]
iic.write_i2c_block_data(0x50, 0, wbuf)
time.sleep(0.2)
rbuf = iic.read_i2c_block_data(0x50, 0, 8)

if len(rbuf) == 8:
    ok = True
    for i in range(8):
        if wbuf[i] != rbuf[i]:
            ok = False
            break
    if ok:
        print('EEPROM读写测试成功。')
    else:
        print('EEPROM读写测试失败。')
else:
    print('EEPROM读写测试失败。')


